using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Diagnostics : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        HttpBrowserCapabilities currentBrowser = Request.Browser;
        ListItem browserName = new ListItem
            ("Recommended Browser: IE 6.0 (or later) ::: Your Browser: " + currentBrowser.Browser + " " + currentBrowser.Version);
        ListItem browserPlatform = new ListItem
            ("Recommended Browser Platform: WinXP, Windows 2003 (or later), or Mobile Devices ::: Your Platform: " + currentBrowser.Platform);
        ListItem browserTables = new ListItem
            ("Table Support Recommended ::: Your Browser's Table Support: " + currentBrowser.Tables.ToString());
        ListItem browserCookies = new ListItem
            ("Cookie Support Recommended ::: Your Browser's Cookie Support: " + currentBrowser.Cookies.ToString());
        ListItem browserVBS = new ListItem
            ("Visual Basic Script Support Recommended ::: Your Browser's Visual Basic Script Support: " + currentBrowser.VBScript.ToString());
        ListItem browserJS = new ListItem
            ("Recommended ECMA Script Version: 1.0 (or later) ::: Your Browser's ECMA Script Version:" + currentBrowser.EcmaScriptVersion.ToString());
        blBrowserReqs.Items.Add(browserName);
        blBrowserReqs.Items.Add(browserPlatform);
        blBrowserReqs.Items.Add(browserTables);
        blBrowserReqs.Items.Add(browserCookies);
        blBrowserReqs.Items.Add(browserVBS);
        blBrowserReqs.Items.Add(browserJS);
        Page.Header.Title = "Browser Recommendations Complete";
		try
		{
			string dbStatus = ConfigurationManager.ConnectionStrings["AdvWorks"].ConnectionString;
			System.Data.SqlClient.SqlConnection sqlConn = new System.Data.SqlClient.SqlConnection(dbStatus);
			sqlConn.Open();
			if (sqlConn.State.ToString() == "Open")
				lblDatabaseStatus.Text = "Database is available";
			else
				lblDatabaseStatus.Text = "Database is currently unavailable";
			sqlConn.Close();
		}
		catch 
		{
			lblDatabaseStatus.Text = "Database is currently unavailable";
		}
    }
}
